package Test;

import com.mapper.StudentSMapper;
import com.mapper.UsersMapper;
import com.mapper.WorkerMapper;
import com.pojo.StudentS;
import com.pojo.Users;
import com.pojo.Worker;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class StudentSTest {
    @Test
    public void selectStudentSByIdTest(){
        SqlSession session = MyBatisUtils.getSqlSession();
        StudentSMapper mapper = session.getMapper(StudentSMapper.class);
        StudentS students = mapper.selectStudentsById(2);
        System.out.println(students);
        session.close();
    }

    @Test
    public void updateStudentSTest(){
        SqlSession session = MyBatisUtils.getSqlSession();
        StudentSMapper mapper = session.getMapper(StudentSMapper.class);
        StudentS students = new StudentS();
        students.setId(4);
        students.setName("李雷");
        students.setAge(21);
        int result = mapper.updateStudents(students);
        if (result>0){
            System.out.println("成功插入"+result+"条数据");
        }else {
            System.out.println("插入数据失败");
        }
        System.out.println(students.toString());
        session.commit();
        session.close();
    }

}
